﻿/// <reference path="jquery/jquery-1.4.1-vsdoc.js" />
var msgCountDom;
var unreadMessageRefreshInterval = 10000; // 10 secs

function StartLoading() {
    $(function() {
        msgCountDom = $('#siteheader #msgcount');
        reqCountDom = $('#siteheader #reqcount');
        try {
            GetAllUnread();
        } catch (e) { }
    });
}

function GetAllUnread() {
    $.ajax({
        type: 'POST',
        url: relRootPath + '/Services/MessageServices.asmx/GetAllUnreadItems',
        data: { userId: userid },
        success: ShowAllUnreadItems,
        beforeSend: function () { }
    });
}

function ShowAllUnreadItems(data, s, x) {
    var d = eval('[' + $(data).text() + ']')[0];
    try {
        if(eval(d.Message)!=0)
            msgCountDom.html(" <span class='msgc msgc-m'>(" + d.Message + ")</span>");
        if (eval(d.Request) != 0)
            reqCountDom.html(" <span class='msgc msgc-r'>(" + d.Request + ")</span>");
    }
    catch (ex) { }
}